home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / clang / netclb23.zip / EXAMPLES.EXE / BINLIST.C next >
C/C++ Source or Header  |  1994-05-20  |  3KB  |  98 lines

  1. /***************************************************************************/
  2. /* File:             BINLIST.C                                             */
  3. /*                                                                         */
  4. /* Function:         List all users from the bindery.                      */
  5. /*                                                                         */
  6. /* Usage:            binlist                                               */
  7. /*                                                                         */
  8. /* Functions Called: GetPreferredConnectionID                              */
  9. /*                   GetDefaultConnectionID                                */
  10. /*                   SetPreferredConnectionID                              */
  11. /*                   GetPrimaryConnectionID                                */
  12. /*                   ISShellLoaded                                         */
  13. /*                   ScanBinderyObject                                     */
  14. /*                   ReadPropertyValue                                     */
  15. /*                                                                         */
  16. /***************************************************************************/
  17. #include <conio.h>
  18. #include <dos.h>
  19.  
  20. #ifndef TURBOC
  21. #include <search.h>
  22. #endif
  23.  
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include <string.h>
  27. #include <time.h>
  28.  
  29. #include "netware.h"
  30.  
  31. #define   FALSE   0
  32. #define   TRUE    (!FALSE)
  33.  
  34. /**********************************************************************/
  35.  
  36. void main()
  37. {
  38. long object_id;
  39. int object_type;
  40. char object_name[OBJECT_LENGTH];
  41. int prefserver;
  42. int thisserver;
  43. char wildname[] = "*";
  44. int ret_code,rcode;
  45. byte has_props,security,object_flag;
  46. char property_value[129];
  47. byte more_segs,prop_flag;
  48.  
  49.    if (IsShellLoaded() != SUCCESS)
  50.    {
  51.       printf("*** No netware shell loaded ***\n");
  52.       exit(255);
  53.    }
  54.  
  55.    if ((prefserver = GetPreferredConnectionID()) == 0)
  56.    {
  57.       if ((thisserver = GetDefaultConnectionID()) == 0)
  58.          thisserver = GetPrimaryConnectionID();
  59.       SetPreferredConnectionID( thisserver );
  60.    }
  61.    else
  62.       thisserver = prefserver;
  63.  
  64.    ret_code = 0;
  65.    object_id = 0xffffffff;
  66.    
  67.    while( ret_code == 0 )
  68.    {
  69.      ret_code = ScanBinderyObject( USER, wildname , &object_id ,
  70.                                    &object_type,object_name,
  71.                                    &has_props,&security,&object_flag);
  72.      if (ret_code != 0)
  73.      {
  74.         if (ret_code == 0xfc)
  75.            printf("No more user names\n");
  76.         else
  77.            printf("ScanBinderyObject failed: %d\n",ret_code);
  78.      }
  79.      else
  80.      {
  81.         if (has_props == 0)
  82.            property_value[0] = '\0';
  83.         else
  84.         {
  85.            rcode = ReadPropertyValue( USER , object_name , IDENT ,
  86.                                       0x01 , property_value ,
  87.                                       &more_segs , &prop_flag );
  88.            if (rcode != 0)
  89.               property_value[0] = '\0';
  90.         }
  91.         printf("%s - %s\n",object_name,property_value);
  92.      }
  93.    }
  94.  
  95.    if (thisserver != prefserver)   /* reset preferred server */
  96.       SetPreferredConnectionID( prefserver );
  97. }
  98.